package com.chuangmei.com.arindoorlocationsystem.config.fragment;

import android.view.View;
import android.widget.TextView;

import com.chuangmei.com.arindoorlocationsystem.R;
import com.chuangmei.com.arindoorlocationsystem.base.BaseFragment;
import com.chuangmei.com.arindoorlocationsystem.config.ConfigMessageActivity;
import com.chuangmei.com.arindoorlocationsystem.utils.LogUtils;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;


/**
 * 帮助Fragment
 */
public class HelpFragment extends BaseFragment {


    @BindView(R.id.mTV_message)
    TextView mTV_message;
    private Unbinder unbinder;


    @Override
    protected int setLayout() {
        return R.layout.fragment_help;
    }

    @Override
    protected void initView(View view) {
        unbinder = ButterKnife.bind(this, view);
    }


    @OnClick(R.id.mBT_help)
    public void onViewClicked() {
        Map<String, String> map = new HashMap<>();
        map.put("phone", "12345678912");
        map.put("pwd", "123456");
        map.put("loginType", "12");

        OkGo.<String>post("http://www.xianmiapp.com/user/newLogin").tag("hao").params(map).execute(new StringCallback
                () {

            @Override
            public void onSuccess(Response<String> response) {
                mTV_message.setText(response.body());
            }

            @Override
            public void onError(Response<String> response) {
                super.onError(response);
                LogUtils.bugErr(response.body().concat("msg"));
            }
        });
    }

    @Override
    public void onResume() {
        super.onResume();
        ((ConfigMessageActivity) getActivity()).chengTitle(getResources().getString(R.string.help_title));
    }

    @Override
    public void onPause() {
        super.onPause();
        ((ConfigMessageActivity) getActivity()).chengTitle(getResources().getString(R.string.config_title));
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
